package com.liam.chinesevietnamesecorpus.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liam.chinesevietnamesecorpus.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 用户Mapper接口
 * 
 * @author Liam
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户名查询用户
     * 
     * @param username 用户名
     * @return 用户信息
     */
    @Select("SELECT * FROM user WHERE username = #{username} AND status != 'deleted'")
    User selectByUsername(String username);

    /**
     * 根据邮箱查询用户
     * 
     * @param email 邮箱
     * @return 用户信息
     */
    @Select("SELECT * FROM user WHERE email = #{email} AND status != 'deleted'")
    User selectByEmail(String email);

    /**
     * 根据用户名或邮箱查询用户（用于登录）
     * 
     * @param username 用户名或邮箱
     * @return 用户信息
     */
    @Select("SELECT * FROM user WHERE (username = #{username} OR email = #{username}) AND status = 'active'")
    User selectByUsernameOrEmail(String username);
}
